/*!
\copyright  Copyright (c) 2024 Qualcomm Technologies International, Ltd.
            All Rights Reserved.
            Qualcomm Technologies International, Ltd. Confidential and Proprietary.
\file
\brief      Internal Data interface for SPP Loopback test application.
*/

#ifndef SPP_TEST_PRIVATE_DATA_H
#define SPP_TEST_PRIVATE_DATA_H

#ifdef INCLUDE_SPPS_LOOPBACK_TEST
#include <connection.h>

#define SPP_SERVICE_RECORD_CHANNEL_INDEX    24   /*! index in SPP SDP record for channel */
#define SPP_CLASS_OF_DEVICE                 0    /*! SPP COD */
#define SPP_INVALID_CONN_ID                 0xFF /*! Invalid id when there is no connection*/

/*! \brief spp server instance index */
typedef enum {
    spp_server_instance_1,
    spp_server_instance_2,
    spp_max_instances
}spp_server_instance;

typedef struct
{
    /*! Service handler for SPP loopback application, 
        always TaskData should be the first member 
        of this structure */
    TaskData                spp_service_handler_task;
    /*! Synergy Queue id for the respective instance */
    uint16                  spp_queue_id;
    /*! Spp instance id to be initialized */
    uint8                   spp_instance_id;
    /*! RFCOMM local server channel */
    uint8                   local_server_channel;
    /*! connection identifier for the respective instance */
    uint16                  spp_connection_id;
} spp_service_data_t;

/*SPP service data block */
extern spp_service_data_t *spp_service_test_data[spp_max_instances];

/******************************* Utility Functions *******************************/
/*! \brief To check if the respective instance has been instantiated or not */
#define sppTest_IsInstanceValid(spp_instance_index) (((spp_instance_index < spp_max_instances) && (spp_service_test_data[spp_instance_index]))?TRUE:FALSE)
/*! \brief Retrieve SPP conn id from the respective instance */
#define sppTest_GetSppConnIdFromIndex(spp_instance_index) (sppTest_IsInstanceValid(spp_instance_index))?\
                                                           (spp_service_test_data[spp_instance_index]->spp_connection_id):\
                                                            SPP_INVALID_CONN_ID
/*! \brief Retrieve SPP loopback application task handler from the respective instance, Instance validity shall be checked by
           the caller of this function */
#define sppTest_GetTaskHandler(spp_instance_index) spp_service_test_data[spp_instance_index]->spp_service_handler_task
/*! \brief Retrieve SPP Synergy SPP Queue id from the respective instance*/
#define sppTest_GetSppQueueIdFromIndex(spp_instance_index) (sppTest_IsInstanceValid(spp_instance_index))?\
                                                            (spp_service_test_data[spp_instance_index]->spp_queue_id):\
                                                            CSR_SCHED_QID_INVALID
/*! \brief Retrieve RFCOMM SPP Local channel id from the respective instance */
#define sppTest_GetSppLocalChannelIdFromIndex(spp_instance_index) (sppTest_IsInstanceValid(spp_instance_index))?\
                                                                  (spp_service_test_data[spp_instance_index]->local_server_channel):\
                                                                  RFC_INVALID_SERV_CHANNEL
/*! \brief To check if there is an active connection with respective instance */
#define sppTest_IsSppConnIdValid(spp_instance_index) ((spp_service_test_data[spp_instance_index]->spp_connection_id != SPP_INVALID_CONN_ID)?TRUE:FALSE)


/*! \brief Configure SPP streams enabling data loopback over the source and sync endpoint innstance validity shall be checked by
           the caller of this function */
void sppTest_ConfigureSppStreams(uint8 spp_instance_index);

/*! \brief Set the connection id to the respective instance while marshalling application data */
void sppTest_SetSppConnIdForIndex(uint8 spp_instance_index, uint16 spp_conn_id);

#endif // INCLUDE_SPPS_LOOPBACK_TEST
#endif // SPP_TEST_PRIVATE_DATA_H
